#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <assert.h>

char* my_strncat(char* str1, const char* str2, int n)
{
	assert(str1 && str2);
	char* ret = str1;
	while (*str1)
	{
		str1++;
	}
	for (int i = 0; i < n; i++)
	{
		if (*str2)
		{
			*str1++ = *str2++;
		}
		else
		{
			break;
		}
	}
	*str1 = '\0';
	return ret;
}

int main()
{
	char arr1[] = "abcdef";
	char arr2[20] = "xx\0xxxxxxxxx";
	my_strncat(arr2, arr1, 15);
	printf("%s", arr2);
	return 0;
}